module two {
	export class LoginPage extends BaseComponent {
		public constructor() {
			super("LoginPage");
		}

		public btn_start: eui.Button;
		public bg: eui.Image;
		public bg2:eui.Image;
		public star:eui.Image;

		private isOver: boolean = false;

		public flag_circle: eui.Image;
		public flag_star: eui.Image;

		protected created(): void {
			super.created();

			two.addTap(this.btn_start, () => {
				if (this.isOver) {

				}
				else {
					this.showIme();
					let page = two.changePage("login2") as Login2Page;
					page.refreshData("onInitData", { quick: 1 });
				}
			});

			this.showTips();

			egret.Tween.get(this.flag_circle, { loop: true }).to({ rotation: 360 }, 4000);


			this.star.scaleX = this.star.scaleY = 3.525;
			this.star.rotation = -15.2;
			this.star.x = -246;
			this.star.y = 1152;
			egret.Tween.get(this.star).to({
				x: 174,
				y: 876,
				scaleX: 0.94,
				scaleY: 0.94,
				rotation: 0
			}, 19.9 * 1000);


			this.bg.scaleX = this.bg.scaleY = 1.155;
			this.bg.rotation = -15.2;
			this.bg.x = 284;
			this.bg.y = 641;
			egret.Tween.get(this.bg).to({
				scaleX: 0.667,
				scaleY: 0.667,
				x: 426,
				y: 667,
				rotation: 0
			}, 19.9 * 1000);

			this.bg2.scaleX = this.bg2.scaleY = 3.592;
			this.bg2.rotation = -15.2;
			this.bg2.x = 355;
			this.bg2.y = 746
			egret.Tween.get(this.bg2).to({
				scaleX: 1,
				scaleY: 1,
				x: 435,
				y: 666,
				rotation: 0
			}, 19.9 * 1000);

			this.flag_star.alpha = 0;
			egret.Tween.get(this.flag_star, { loop: true })
				.call(() => {
					this.flag_star.x = one.randomInt(300, 500)
					this.flag_star.y = one.randomInt(400, 900)
				})
				.to({ alpha: 1 }, 2000)
				.to({ alpha: 0 }, 2000);
		}

		public gp_tips: eui.Group;
		private showTips(): void {
			for (let i = 0; i < this.gp_tips.numChildren; i++) {
				let item = this.gp_tips.getChildAt(i);
				item.alpha = 0;
				let y = item.y;
				item.y = y + 20;
				let t = egret.Tween.get(item).wait(400 + i * (1000 + 1200)).to({ alpha: 1, y: y }, 1200);

				if (i == this.gp_tips.numChildren - 1) {
					t.wait(3500).call(() => {
						let page = two.changePage("login2", 4) as Login2Page;
						page.refreshData("onInitData", { quick: 0 });
					})
				}
			}
		}

		private showIme(): void {
			for (let i = 0; i < this.gp_tips.numChildren; i++) {
				this.gp_tips.getChildAt(i).alpha = 1;
				egret.Tween.removeTweens(this.gp_tips.getChildAt(i));
			}
		}

		protected removed(): void {
			super.removed();

			egret.Tween.removeTweens(this.flag_circle);
			egret.Tween.removeTweens(this.flag_star);
		}
	}

	two.setClassMap("login", "two.LoginPage");
}